/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app.gnucash.client.widget;

import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.util.Padding;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.ButtonBar;
import com.extjs.gxt.ui.client.widget.button.ToggleButton;
import com.extjs.gxt.ui.client.widget.layout.BoxLayout.BoxLayoutPack;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayout.VBoxLayoutAlign;
import com.extjs.gxt.ui.client.widget.layout.VBoxLayoutData;
import com.google.gwt.user.client.Element;

/**
 *
 * @author cc
 */
public class NavButtons extends LayoutContainer {

    private ContentPanel lcwest;

    @Override
    protected void onRender(Element parent, int index) {
        super.onRender(parent, index);
        setScrollMode(Scroll.AUTO);

        lcwest = new ContentPanel();
        lcwest.setHeaderVisible(false);
        lcwest.setSize(150, 600);
        lcwest.setBorders(false);
        lcwest.setLayout(new FitLayout());

        LayoutContainer c = new LayoutContainer();
        VBoxLayout layout = new VBoxLayout();
        layout.setPadding(new Padding(5));
        layout.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
        layout.setPack(BoxLayoutPack.START);
        c.setLayout(layout);

        VBoxLayoutData layoutData = new VBoxLayoutData(new Margins(0, 0, 5, 0));
        c.add(new Button("主界面"), layoutData);
        c.add(new Button("金融机构"), layoutData);
        c.add(new Button("账户"), layoutData);

        VBoxLayoutData layoutData2 = new VBoxLayoutData(new Margins(0));
        c.add(new Button("交易类别"), layoutData2);


        VBoxLayoutData vBoxData = new VBoxLayoutData(5, 5, 5, 5);
        vBoxData.setFlex(1);

        ButtonBar hp = new ButtonBar();
        hp.add(new Button("主界面"));
        hp.add(new Button("金融机构"));
        hp.add(new Button("账户"));
        hp.add(new Button("交易类别"));
        lcwest.add(c);
        add(lcwest);
    }

    private ToggleButton createToggleButton(String name, Listener<ButtonEvent> l) {
        ToggleButton button = new ToggleButton(name);
        button.setToggleGroup("vboxlayoutbuttons");
        button.addListener(Events.Toggle, l);
        button.setAllowDepress(false);
        return button;
    }
}
